﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Diagnostics;
using Microsoft.Practices.Unity;
using System.Data.Entity;
using DNA.Mvc.Data;

namespace DNA.Mvc
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public partial class WebApp : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            Bootstrapper.RegisterRoutes(RouteTable.Routes);
            routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = "" });
        }

        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            //filters.Add(new TraceErrorFilter());
            filters.Add(new HandleErrorAttribute());
        }

        protected void Application_PreRequestHandlerExecute(object sender, EventArgs e)
        {
            Bootstrapper.SetCulture();
        }

        protected void Application_Start()
        {

            //ViewEngines.Engines.Clear();
            //ViewEngines.Engines.Add(new RazorViewEngine());

            AreaRegistration.RegisterAllAreas();
            RegisterRoutes(RouteTable.Routes); 
            Bootstrapper.RegisterTypes();
            RegisterGlobalFilters(GlobalFilters.Filters);
            Bootstrapper.RegisterGlobalFilters(GlobalFilters.Filters);
            Bootstrapper.Init();
        }
    }
}